package org.common4j2ee.stock.service.user;


import java.util.List;

import org.common4j2ee.stock.dao.user.RoleDaoImpl;
import org.common4j2ee.stock.dao.utils.Page;
import org.common4j2ee.stock.dao.utils.PropertyFilter;
import org.common4j2ee.stock.entity.user.Role;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;


@Component
@Transactional
public class RoleManager {

	@Autowired
	private RoleDaoImpl roleDao;

	public List<Role> getAllRole() {
		return roleDao.getAll();
	}

	/**
	 * 使用属性过滤条件查询用户.
	 */
	@Transactional(readOnly = true)
	public Page<Role> searchRole(Page<Role> page, List<PropertyFilter> filters) {
		return roleDao.findPage(page, filters);
	}

	public void saveRole(Role role) {
		roleDao.save(role);
	}

	public void deleteRole(Long id) {
		roleDao.delete(id);
	}
	@Transactional(readOnly = true)
	public boolean isRoleNameUnique(String newLoginName, String oldLoginName) {
		return roleDao.isPropertyUnique("name", newLoginName, oldLoginName);
	}

	public Role getRole(Long id) {
		return roleDao.get(id);
	}

	
	
}
